package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import org.testng.annotations.Test;

import com.example.fw.Contacts;

public class ContactModificationTests extends TestBase {
	
	@Test (dataProvider = "existingAndRandomContacts", dataProviderClass = ContactDataGenerator.class)
	public void testRandomContactCanBeModify(ContactObject contactBeforeModification, ContactObject contactAfterModification) throws Exception {
		Contacts oldList = app.getContactHelper().getContacts();
		//action
		app.getContactHelper().modifyContact(contactBeforeModification, contactAfterModification);
		//verification
		Contacts newList = app.getContactHelper().getContacts();
		assertThat(newList, equalTo(oldList.withRemoved(contactBeforeModification).withAdded(contactAfterModification)));
	}
	
}
